//
//  MoreViewController.m
//  笔记1
//
//  Created by  on 2022/11/6.
//

#import "MoreViewController.h"
#import "Setting.h"

@interface MoreViewController ()
@property (strong, nonatomic) IBOutlet UITableView *tableView;
@end

@implementation MoreViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initUI];
}
- (void)initUI
{
    self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectZero];
    [self.tableView registerNib:[Setting nib] forCellReuseIdentifier:[Setting ID]];
}

- (IBAction)actionForBtn:(UIButton *)sender {
    if (self.block) {
        self.block(@"");
    }
    [self dismissViewControllerAnimated:NO completion:^{
        [NotifyTool post:notifyNoteUpdate];
    }];
}
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [super touchesEnded:touches withEvent:event];
    [NotifyTool post:notifyNoteUpdate];
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.array.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    Setting *cell = [tableView dequeueReusableCellWithIdentifier:[Setting ID]];
    cell.name.text = LS(self.array[indexPath.row]);
    cell.img.image = [UIImage imageNamed:self.icons[indexPath.row]];
    cell.nameLeft.constant = 20;
    cell.line.hidden = self.array.count == indexPath.row + 1;
    return cell;
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return nil;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    return nil;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self dismissViewControllerAnimated:NO completion:^{
        if (self.block) {
            self.block(self.array[indexPath.row]);
        }
    }];
 
}

@end

